/*    */ package com.zimbra.qa.unittest;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.Config;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AccountTestUtil
/*    */ {
/*    */   public static final String DEFAULT_PASSWORD = "test123";
/*    */   
/*    */   public static boolean accountExists(String userName)
/*    */     throws ServiceException
/*    */   {
/* 38 */     String address = getAddress(userName);
/* 39 */     Account account = Provisioning.getInstance().get(Key.AccountBy.name, address);
/* 40 */     return account != null;
/*    */   }
/*    */   
/*    */   public static Account getAccount(String userName) throws ServiceException
/*    */   {
/* 45 */     String address = getAddress(userName);
/* 46 */     return Provisioning.getInstance().get(Key.AccountBy.name, address);
/*    */   }
/*    */   
/*    */   public static String getDomain() throws ServiceException
/*    */   {
/* 51 */     Config config = Provisioning.getInstance().getConfig("zimbraDefaultDomainName");
/* 52 */     String domain = config.getAttr("zimbraDefaultDomainName", null);
/* 53 */     assert ((domain != null) && (domain.length() > 0));
/* 54 */     return domain;
/*    */   }
/*    */   
/*    */   public static Mailbox getMailbox(String userName) throws ServiceException
/*    */   {
/* 59 */     Account account = getAccount(userName);
/* 60 */     return MailboxManager.getInstance().getMailboxByAccount(account);
/*    */   }
/*    */   
/*    */   public static String getAddress(String userName) throws ServiceException
/*    */   {
/* 65 */     if (userName.contains("@")) {
/* 66 */       return userName;
/*    */     }
/* 68 */     return userName + "@" + getDomain();
/*    */   }
/*    */   
/*    */   public static String getAddress(String userName, String domainName)
/*    */   {
/* 73 */     return userName + "@" + domainName;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/AccountTestUtil.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */